<?php
/**
 * Copyright (C), 2021-2021, Shall Buy Life info. Co., Ltd.
 * FileName: PeopleFactory.php
 * Description: 说明
 *
 * @author lwl
 * @Create Date    2021/11/18 14:58
 * @Update Date    2021/11/18 14:58 By lwl
 * @version v1.0
 */

namespace App\DesignPattern\Factory;

class PeopleFactory
{
    private static $instance = null;

    public static function getInstance()
    {
        if (is_null(self::$instance)) {
            self::$instance = new self();
        }

        return self::$instance;
    }

    /**
     * 防止 new 多个实列
     * 必须私有，别问为啥 上面说原因了
     */
    private function __construct()
    {

    }

    /**
     * 防止clone 多个实列
     * 必须私有，别问为啥 上面说原因了
     */
    private function __clone()
    {

    }

    /**
     * 防止反序列化
     * 必须私有，别问为啥 上面说原因了
     */
    private function __wakeup()
    {

    }

    /**
     * 业务逻辑，自己去写
     */
    public function getPeople(string $class)
    {
        $classPath = "\\App\\DesignPattern\\" . $class;
        $result = $classPath::getInstance()->eat();
        dd($result);
    }
}

